<?php

namespace app\models;

use Yii;
use yii\behaviors\SluggableBehavior;

/**
 * This is the model class for table "menu".
 *
 * @property string $id 菜单id
 * @property string $name 菜单名
 * @property string $route 路由
 * @property string $icon 图标
 * @property int $pid 父菜单
 * @property string $extend
 */
class SlugModel extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'menu';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['pid'], 'integer'],
            [['name', 'route', 'icon'], 'string', 'max' => 255],
            [['extend'], 'string', 'max' => 1023],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => '菜单id',
            'name' => '菜单名',
            'route' => '路由',
            'icon' => '图标',
            'pid' => '父菜单',
            'extend' => 'Extend',
        ];
    }

    public function behaviors()
    {
        return [
            [
                'class' => SluggableBehavior::class,
                'attribute' => 'name',
                'slugAttribute' => 'extend',
            ],
        ];
    }
    public static $db = null;
    public static function getDb()
    {
        return self::$db;
    }
}
